import { InputQuestion, QuestionBase, RadioQuestion, SelectQuestion } from '@/components/public-template';
import { getMenNum } from '@/utils';
import { regExp } from '@/utils/regExp';
import { Api as ApiSystem } from '@/config/api/system';

class IndexService {
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new RadioQuestion({
        key: 'dataPermission',
        label: '数据权限',
        value: 0,
        options: [
          {
            label: '全部',
            value: 0
          },
          {
            label: '自定义',
            value: 1
          }
        ],
        state: {
          changeOptions: {
            0: [getMenNum('deptPerssiomId', 'hidden', true)],
            1: [getMenNum('deptPerssiomId', 'hidden', false)]
          }
        }
      }),
      new SelectQuestion({
        key: 'deptPerssiomId',
        label: '部门',
        value: [],
        defaultValue: [],
        type: 'tree',
        state: {
          url: ApiSystem.orgTreeData,
          protType: 'post',
          nameKey: 'name',
          nameValue: 'id',
          nameChildren: 'childOrg',
          treeCheckable: true,
          changeParams: [{ deptPerssiomName: 'label', deptPerssiomid: 'value' }]
        }
      })
    ];
    return questions;
  }
}

export default new IndexService();
